import chardet

if __name__ == '__main__':
    filename = 'd:\\new  2.txt'
    f = open(filename, 'r')
    fstr = f.read()
    print chardet.detect('ok')
